--编写者：alt
--功能介绍：所有生物对角色无主动仇恨
--使用方法：直接粘贴到模组环境 修改adam为人物tag

do
    --所有生物对角色无主动仇恨
    local function check(target)
        return target:HasTag("lambris_hide")
    end
    local Combat = require "components/combat"
    local fakeSetTarget = function(self, target, ...)
        if target and check(target) then
            return
        end
        if self.lambris_oldSetTarget then
            return self.lambris_oldSetTarget(self, target, ...)
        end
    end
    local oldTryRetarget = Combat.TryRetarget
    function Combat:TryRetarget(...)
        self.lambris_oldSetTarget = self.SetTarget
        self.SetTarget = fakeSetTarget
        oldTryRetarget(self, ...)
        self.SetTarget = self.lambris_oldSetTarget
    end

    local oldSetTarget = Combat.SetTarget
    function Combat:SetTarget(target, ...)
        if target and target.lambris_notarget and check(target) then
            return
        end
        return oldSetTarget(self, target, ...)
    end

    local ChildSpawner = require "components/childspawner"
    local oldDoSpawnChild = ChildSpawner.DoSpawnChild
    function ChildSpawner:DoSpawnChild(target, prefab, radius, ...)
        if target then
            target.lambris_notarget = true
            local child, b, c = oldDoSpawnChild(self, target, prefab, radius, ...)
            target.lambris_notarget = nil
            return child, b, c
        end
        return oldDoSpawnChild(self, target, prefab, radius, ...)
    end
end
